package com.health.viewscontrols.lvyuejl;

import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;

import com.health.R;
import com.health.adapter.QYDoctersAdapter;
import com.health.adapter.SpinnerAdapter;
import com.health.model.LvYueFuWuBean;
import com.health.tablebean.ARCHIVE_BASEINFO;
import com.health.tablebean.BD_ORGANIZE_EMPLOYEE;
import com.health.tablebean.JTYSCustomerDoctorCont;
import com.health.tablebean.JTYS_SignPictureData;
import com.health.tools.GlobalConts;
import com.health.tools.GlobalContsJTYS;
import com.health.tools.ImageTools;
import com.health.tools.SPUtil;
import com.health.viewscontrols.NovaActivity;
import com.health.viewscontrols.NovaApplication;
import com.health.viewscontrols.PersonalFileActivity;
import com.health.viewscontrols.qyinfo.QYInfo;
import com.health.viewscontrols.qyinfo.QianMingActivity;
import com.health.viewscontrols.tupian.ClipActivity1;
import com.health.widget.EditTextWithDate;
import com.novabluetooth.services.BluetoothConstant;
import com.novabluetooth.views.ExamHistoryActivity;

import java.io.File;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 履约记录表
 * Created by John on 2019/2/28.
 */

public class LvYueJiLuActivity1 extends NovaActivity {
    Button btn_back;//返回
    TextView title;//标题
    Button btn_up;//保存
    ARCHIVE_BASEINFO userinfo = null;
    EditTextWithDate ed_date;//服务时间
    TextView lvyue_name;//姓名
    TextView lvYue_age;//年龄
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    EditText lvyueHight;//身高
    EditText lvyueWeight;//体重
    Button lvyueWeightBtn;//
    EditText lvyueTzzs;//体质指数
    EditText lvyueHuxi;//呼吸频率
    EditText lvyueXinlv;//心率
    Button lvyueXinlvBtn;//
    EditText lvyueTiwen;//体温
    Button lvyueTiWenBtn;//
    EditText lvyueXueYaGao;//收缩压
    EditText lvyueXueYaDi;//舒张压
    Button lvyueXueYaBtn;//
    EditText lvyueXueTang;//血糖
    Spinner xuetang_spinner;//血糖下拉
    String xuetangType="1";//血糖类型
    Button lvyueXueTangBtn;
    EditText lvyueJkgl;//健康管理
    EditText lvyueZyqk;//住院情况
    EditText lvyueZzqk;//转诊情况
    Spinner lvyuedocName;//医生姓名
    ImageView lvyueDocImg;
    Button lvyueDocBtn;
    TextView lvyueHuanName;//患者姓名
    ImageView lvyueHuanImg;
    Button lvyueHuanBtn;
    EditText lvyueBeiZhu;//备注

    private int pos_doc = 0;

    // 患者签名
    private String strPatientSignPath = "";

    // 医生签名
    private String strDocSignPath = "";

    // 患者
    private final int REQUEST_CODE_PATIENT = 11;
    // 医生
    private final int REQUEST_CODE_DOCTOR = 12;

    boolean isSave=false;//是否保存

    private String str = UUID.randomUUID().toString();
    String uuid = str.substring(0, 8) + str.substring(9, 13) + str.substring(14, 18) + str.substring(19, 23) + str.substring(24, 30);

    List<String> xuetangList = new ArrayList<String>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lvyue1);
        userinfo = NovaApplication.getUserInfo();
        xuetangList.add("空腹血糖");
        xuetangList.add("餐后1小时血糖");
        xuetangList.add("餐后2小时血糖");
        xuetangList.add("随机血糖");
        findViews();
        setListeners();
        setData();
    }

    @Override
    public void findViews() {
        btn_back=findViewById(R.id.btn_back);
        title=findViewById(R.id.title);
        title.setText("履约服务记录表");
        btn_up=findViewById(R.id.btn_up);

        ed_date=findViewById(R.id.ed_date);
        lvyue_name=findViewById(R.id.lvyue_name);
        lvYue_age=findViewById(R.id.lvyue_age);

        lvyueHight=findViewById(R.id.lvyue_hight);
        lvyueWeight=findViewById(R.id.lvyue_weight);
        lvyueWeightBtn=findViewById(R.id.lvyue_btn_weight);
        lvyueTzzs=findViewById(R.id.lvyue_tzzs);
        lvyueHuxi=findViewById(R.id.lvyue_huxi);
        lvyueXinlv=findViewById(R.id.lvyue_xinlv);
        lvyueXinlvBtn=findViewById(R.id.lvyue_btn_xinlv);

        lvyueTiwen=findViewById(R.id.lvyue_tiwen);
        lvyueTiWenBtn=findViewById(R.id.lvyue_btn_tiwen);
        lvyueXueYaGao=findViewById(R.id.lvyue_xueya_gao);
        lvyueXueYaDi=findViewById(R.id.lvyue_xueya_di);
        lvyueXueYaBtn=findViewById(R.id.lvyue_btn_xueYa);
        lvyueXueTang=findViewById(R.id.lvyue_xuetang);
        xuetang_spinner=findViewById(R.id.xuetang_spinner);
        SpinnerAdapter spinnerAdapter=new SpinnerAdapter(LvYueJiLuActivity1.this,xuetangList);
        xuetang_spinner.setAdapter(spinnerAdapter);
        lvyueXueTangBtn=findViewById(R.id.lvyue_btn_xueTang);
        lvyueJkgl=findViewById(R.id.lvyue_jkgl);
        lvyueZyqk=findViewById(R.id.lvyue_zyqk);
        lvyueZzqk=findViewById(R.id.lvyue_zzqk);
        lvyuedocName=findViewById(R.id.lvyue_docname);
        lvyueDocImg=findViewById(R.id.img_doctorsign);
        lvyueDocBtn=findViewById(R.id.btn_doctorsign);
        lvyueHuanName=findViewById(R.id.lvyue_juming_name);
        lvyueHuanImg=findViewById(R.id.img_patientsign);
        lvyueHuanBtn=findViewById(R.id.btn_patientsign);
        lvyueBeiZhu=findViewById(R.id.lvyue_beizhu);


    }

    /**
     * 设置签名图片
     */
    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    private void initSignPhotoData(JTYSCustomerDoctorCont cont) {
//        List<JTYS_SignPictureData> pictures = NovaApplication.fdbmanger.findAllByWhere(JTYS_SignPictureData.class,
//                "CardNum = '" + userInfo.getIDCARD() + "'");
        List<JTYS_SignPictureData> pictures = NovaApplication.fdbmanger.findAllByWhere(JTYS_SignPictureData.class,
                "CardNum = '" + cont.getCardNum() + "'");


        for (JTYS_SignPictureData pic : pictures) {
            switch (pic.type()) {
                case "4":// 医生签名
                    setSign(pic.getPhotoPath(), lvyueDocImg);
                    break;
                case "5":// 患者签名
                    setSign(pic.getPhotoPath(), lvyueHuanImg);
                    break;

                default:
                    break;
            }
        }

    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
    /**
     * 客户身份证号_签约时间_用户类型_创建时间时分秒_随机数.png
     * <p>
     * 370883198806046521_2017-12-07_1_20171207104138_8140.png
     *
     * @param type 1 医生 签名 2 患者签名 3 其他照片
     * @return
     * @author 鹿云龙
     * @date 2017年12月26日 上午10:13:28
     */
    private String getPhotoPath(String type) {
        if (type == null) {
            return null;
        }
        String str = "";
        File file = null;

        file = new File(Environment.getExternalStorageDirectory() + "/PublicHealth/LvyueSign/");
        str = Environment.getExternalStorageDirectory() + "/PublicHealth/LvyueSign/" + userinfo.getIDCARD() + "_"
                + ed_date.getText().toString() + "_" + type + "_" + sdf.format(new Date()) + "_"
                + (int) ((Math.random() * 9 + 1) * 1000) + ".png";

        if (!file.exists()) {
            file.mkdirs();
        }
        return str;
    }
    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    private void setSign(String imgPath, ImageView v) {
        // String result = "";

        if (!TextUtils.isEmpty(imgPath)) {
            Log.e("***", "照片src：" + imgPath);
            File file = new File(imgPath);
            if (file.exists()) {
                // v.setbacImageBitmap(ImageTools.readBitmapAutoSize(imgPath));
                v.setVisibility(View.VISIBLE);
                v.setBackground(new BitmapDrawable(null, ImageTools.readBitmapAutoSize(imgPath)));
            } else {
                v.setImageBitmap(null);
            }
        }
    }


    /**
     * 初始化赋值
     */
    public void setData(){
        lvyue_name.setText(userinfo.getCUSTOMERNAME());
        int age = GlobalConts.getAge(userinfo.getBIRTHDAY());
        if (age != -1) {
            lvYue_age.setText(String.valueOf(age) + "岁");
        } else {
            lvYue_age.setText("");
        }

       ed_date.setText(GlobalConts.dateFormat.format(new Date()));
        lvyueHuanName.setText(userinfo.getCUSTOMERNAME());
        bindSpinnerQyDocList(NovaApplication.getDoctorList());


    }
    public void bindSpinnerQyDocList(List<BD_ORGANIZE_EMPLOYEE> bds) {
        // 判断当前城市在数组中的位置并显示
        QYDoctersAdapter adapter_bsc = new QYDoctersAdapter(getApplicationContext(), bds);
        // adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        lvyuedocName.setAdapter(adapter_bsc);
    }

    @Override
    public void setListeners() {
        btn_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        lvyueWeightBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(LvYueJiLuActivity1.this, ExamHistoryActivity.class);
                intent.putExtra("flag", BluetoothConstant.TIZHONG_TYPENAME);
                startActivityForResult(intent, GlobalConts.RequestTizhong);
            }
        });
        lvyueXinlvBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(LvYueJiLuActivity1.this, ExamHistoryActivity.class);
                intent.putExtra("flag", "心率");
                startActivityForResult(intent, GlobalConts.RequestMaiLv);
            }
        });
        lvyueTiWenBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(LvYueJiLuActivity1.this, ExamHistoryActivity.class);
                intent.putExtra("flag", BluetoothConstant.TIWEN_TYPENAME);
                startActivityForResult(intent, GlobalConts.RequestTiwen);
            }
        });
        lvyueXueYaBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(LvYueJiLuActivity1.this, ExamHistoryActivity.class);
                intent.putExtra("flag", BluetoothConstant.XUEYA_TYPENAME);
                startActivityForResult(intent, GlobalConts.RequestXueya);
            }
        });
        lvyueXueTangBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(LvYueJiLuActivity1.this, ExamHistoryActivity.class);
                intent.putExtra("flag", BluetoothConstant.XUETANG_TYPENAME);
                startActivityForResult(intent, GlobalConts.RequestXuetang);
            }
        });

        xuetang_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                xuetangType=position+1+"";
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });


        lvyuedocName.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                pos_doc = position;
                setSpinnerPos(position);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        lvyueHuanBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 患者签名btn
                if (userinfo != null) {


                    if ("重签".equals(lvyueHuanBtn.getText())) {
                        judgeFileIsExistsAndDelete(strPatientSignPath);
                    }

                    Intent intent = new Intent(LvYueJiLuActivity1.this, QianMingActivity.class);
                    // //命名规则： 身份证号_签约时间_用户类型_创建时间时分秒_随机数.png[用户类型： 1 医生 2 患者 3
                    // 其他图片]
                    intent.putExtra(QianMingActivity.SIGNNAME_HEAD, getPhotoPath("5"));
                    startActivityForResult(intent, REQUEST_CODE_PATIENT);
                } else {
                    showTextDialog("没有获取到用户数据");
                }
            }
        });

        lvyueDocBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 医生签名btn
                if (userinfo != null) {


                    if ("重签".equals(lvyueDocBtn.getText())) {
                        judgeFileIsExistsAndDelete(strDocSignPath);
                    }

                    Intent intent = new Intent(LvYueJiLuActivity1.this, QianMingActivity.class);
                    // //命名规则： 身份证号_签约时间_用户类型_创建时间时分秒_随机数.png[用户类型： 1 医生 2 患者 3
                    // 其他图片]
                    intent.putExtra(QianMingActivity.SIGNNAME_HEAD, getPhotoPath("4"));
                    startActivityForResult(intent, REQUEST_CODE_DOCTOR);
                } else {
                    showTextDialog("没有获取到用户数据");
                }
            }
        });
        changeBMI(lvyueHight,lvyueWeight,lvyueTzzs);
        btn_up.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(isSave){
                    showTextDialog("该记录已保存过");
                    return;
                }
                List<LvYueFuWuBean> lvYueFuWuBeans=NovaApplication.fdbmanger.findAllByWhere(LvYueFuWuBean.class,"cardNum='"+ userinfo.getIDCARD()+"' and lvyueDate='"+ ed_date.getText().toString()+"'");
                if(lvYueFuWuBeans.size()>0){
                    showTextDialog("相同服务时间只能添加一条履约记录");
                    return;
                }
                if(TextUtils.isEmpty(lvyueHight.getText())){
                    showTextDialog("请输入身高");
                    return;
                }
                if(TextUtils.isEmpty(lvyueWeight.getText())){
                    showTextDialog("请输入体重");
                    return;
                }
//                if(TextUtils.isEmpty(lvyueHuxi.getText())){
//                    showTextDialog("请输入呼吸频率");
//                    return;
//                }
//                if(TextUtils.isEmpty(lvyueXinlv.getText())){
//                    showTextDialog("请输入心率");
//                    return;
//                }
//                if(TextUtils.isEmpty(lvyueTiwen.getText())){
//                    showTextDialog("请输入体温");
//                    return;
//                }
                if(TextUtils.isEmpty(lvyueXueYaGao.getText())||TextUtils.isEmpty(lvyueXueYaDi.getText())){
                    showTextDialog("请输入血压");
                    return;
                }
//                if(TextUtils.isEmpty(lvyueXueTang.getText())){
//                    showTextDialog("请输入血糖");
//                    return;
//                }

                if(TextUtils.isEmpty(strDocSignPath)){
                    showTextDialog("请家庭医生签名");
                    return;
                }
                if(TextUtils.isEmpty(strPatientSignPath)){
                    showTextDialog("请签约人签名");
                    return;
                }

                LvYueFuWuBean lvyue=new LvYueFuWuBean();
                lvyue.setId(uuid);
                lvyue.setCardNum(userinfo.getIDCARD());
                lvyue.setName(userinfo.getCUSTOMERNAME());
                lvyue.setAge(lvYue_age.getText().toString());
                lvyue.setLvyueDate(ed_date.getText().toString());
                lvyue.setHight(lvyueHight.getText().toString());
                lvyue.setWeight(lvyueWeight.getText().toString());
                lvyue.setTzzs(lvyueTzzs.getText().toString());
//                lvyue.setHuxi(lvyueHuxi.getText().toString());
//                lvyue.setXinlv(lvyueXinlv.getText().toString());
//                lvyue.setTiWen(lvyueTiwen.getText().toString());
                lvyue.setXueyaGao(lvyueXueYaGao.getText().toString());
                lvyue.setXueyaDi(lvyueXueYaDi.getText().toString());
//                lvyue.setXueTang(lvyueXueTang.getText().toString());
                if(!TextUtils.isEmpty(lvyueXueTang.getText())){
                    lvyue.setXueTang(lvyueXueTang.getText().toString());
                    lvyue.setXueTangType(xuetangType);
                }
                if(TextUtils.isEmpty(lvyueJkgl.getText())){
                    lvyue.setJkgl("无");
                }else{
                    lvyue.setJkgl(lvyueJkgl.getText().toString());
                }

                if(TextUtils.isEmpty(lvyueZyqk.getText())){
                    lvyue.setZyqk("无");
                }else{
                    lvyue.setZyqk(lvyueZyqk.getText().toString());
                }

//                if(TextUtils.isEmpty(lvyueZzqk.getText())){
//                    lvyue.setZzqk("无");
//                }else{
//                    lvyue.setZzqk(lvyueZzqk.getText().toString());
//                }
                lvyue.setDocName(NovaApplication.getDoctorList().get(pos_doc).getNAME());
                lvyue.setDocQianMingStr(strDocSignPath);
                lvyue.setHuanQianMingStr(strPatientSignPath);
                if(TextUtils.isEmpty(lvyueBeiZhu.getText())){
                    lvyue.setBeiZhu("无");
                }else{
                    lvyue.setBeiZhu(lvyueBeiZhu.getText().toString());
                }

                NovaApplication.fdbmanger.save(lvyue);
                isSave=true;

                showTextDialog("保存成功");

                finish();

            }
        });
    }

    /**
     * 判断该路径下文件是否存在，存在就删除
     *
     * @param path
     */
    private void judgeFileIsExistsAndDelete(String path) {
        if (!TextUtils.isEmpty(path)) {
            File file = new File(path);
            if (file.exists()) {
                file.delete();
            }
        }
    }

    /**
     * Spinner下拉
     *
     * @param pos
     * @author 王婷婷
     * @date 2017年4月26日 下午6:28:42
     */
    private void setSpinnerPos(int pos) {
//        String user_mobile = NovaApplication.getDoctorList().get(pos).getMOBILE();
//        if (TextUtils.isEmpty(user_mobile)) {
//            doc_phone_edit.setText("");
//        } else {
//            doc_phone_edit.setText(user_mobile);
//        }

        try {
            Field field = AdapterView.class.getDeclaredField("mOldSelectedPosition");
            field.setAccessible(true); // 设置mOldSelectedPosition可访问
            field.setInt(lvyuedocName, AdapterView.INVALID_POSITION); // 设置mOldSelectedPosition的值
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 身高或者体重改变时，BMI的值随之发生改变
     **/
    private void changeBMI(final EditText etHeight, final EditText etWeight, final EditText etBMI) {
        etHeight.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (!TextUtils.isEmpty(etWeight.getText().toString())) {
                    setBMI(etHeight, etWeight, etBMI);
                }else{
                    etBMI.setText("");
                }

                if (TextUtils.isEmpty(s.toString())) {
                    etBMI.setText("");
                }

            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        etWeight.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (!TextUtils.isEmpty(etHeight.getText().toString())) {
                    setBMI(etHeight, etWeight, etBMI);
                }else{
                    etBMI.setText("");
                }
                if (TextUtils.isEmpty(s.toString())) {
                    etBMI.setText("");
                }
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                // TODO Auto-generated method stub

            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
    }
    /**
     * 设置BMI
     *
     * @author 王婷婷
     * @date 2017年4月5日 上午10:48:51
     */
    private void setBMI(EditText etHeight, EditText etWeight, EditText etBMI) {
        try {
            if (TextUtils.isEmpty(etHeight.getText().toString()) || TextUtils.isEmpty(etHeight.getText().toString())) {
                etBMI.setText("");
                return;
            }

            double dh = Double.parseDouble(etHeight.getText().toString()) / 100;
            double dw = Double.parseDouble(etWeight.getText().toString());

            java.text.DecimalFormat df = new java.text.DecimalFormat("#.00");

            etBMI.setText(df.format(GlobalConts.getBMI(dh, dw)) + "");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == GlobalConts.RequestXueya && resultCode == ExamHistoryActivity.ResultXueya) {
            lvyueXueYaGao.setText(data.getStringExtra("高压"));
            lvyueXueYaDi.setText(data.getStringExtra("低压"));

        } else if (requestCode == GlobalConts.RequestTizhong && resultCode == ExamHistoryActivity.ResultTizhong) {
            lvyueWeight.setText(data.getStringExtra("value"));
        }else if (requestCode == GlobalConts.RequestMaiLv && resultCode == ExamHistoryActivity.ResultMaiLv) {
            Log.w("eeeeeeeee", data.getStringExtra("value"));
            lvyueXinlv.setText(data.getStringExtra("value"));
        }else if(requestCode == GlobalConts.RequestTiwen && resultCode == ExamHistoryActivity.ResultTiwen){
            Log.w("eeeeeeeee", data.getStringExtra("value"));
            lvyueTiwen.setText(data.getStringExtra("value"));
        }else if(requestCode == GlobalConts.RequestXuetang && resultCode == ExamHistoryActivity.ResultXuetang){
            Log.w("eeeeeeeee", data.getStringExtra("value"));
            lvyueXueTang.setText(data.getStringExtra("value"));
        }

        Log.e("*****", "结果返回码：" + requestCode + "\n" + resultCode);
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case REQUEST_CODE_PATIENT:
                    if (data.getExtras().containsKey("filePath")) {
                        strPatientSignPath = data.getExtras().getString("filePath");
                        setSign(strPatientSignPath, lvyueHuanImg);
                        lvyueHuanBtn.setText("重签");
                    }
                    break;
                case REQUEST_CODE_DOCTOR:
                    if (data.getExtras().containsKey("filePath")) {
                        lvyueDocBtn.setText("重签");
                        strDocSignPath = data.getExtras().getString("filePath");
                        setSign(strDocSignPath, lvyueDocImg);
                    }
                    break;


                default:
                    break;
            }
        }
    }



   /* *//**
     * 保存图片信息所有的
     *
     * @author 王婷婷
     * @date 2017年12月7日 下午3:36:59
     *//*
    private void saveImgData() {
        Log.e("保存图片",strPatientSignPath+"***"+strDocSignPath);
        // 保存签名图片
        if (TextUtils.isEmpty(strPatientSignPath)) {
        } else {
            /// storage/emulated/0/PublicHealth/Sign/370883198806046521_2017-12-07_1__20171207161645_8987.png
            String[] strs = strPatientSignPath.split("/");

            saveImgDataSingle(strs[strs.length - 1].toString(), strPatientSignPath, "5");
        }

        if (TextUtils.isEmpty(strDocSignPath)) {
        } else {
            /// storage/emulated/0/PublicHealth/Sign/370883198806046521_2017-12-07_1__20171207161645_8987.png
            String[] strs = strDocSignPath.split("/");
            saveImgDataSingle(strs[strs.length - 1].toString(), strDocSignPath, "4");
        }

    }*/

   /* *//**
     * 保存图片信息单张
     *
     * @author 王婷婷
     * @date 2017年12月7日 下午3:36:59
     *//*
    private void saveImgDataSingle(String imgName, String imgPath, String str_type) {
        JTYS_SignPictureData info = new JTYS_SignPictureData();
        info.setID(GlobalContsJTYS.getUUID());
        info.setCardNum(userinfo.getIDCARD());
        info.setYsLoginNumber(SPUtil.getstr_jdrusername(LvYueJiLuActivity.this));

        info.setPhotoName(imgName);
        info.setPhotoPath(imgPath);
        info.setCreateOrgId(NovaApplication.getJgbh());
        String datetimeNow = GlobalContsJTYS.datetimeFormat.format(new Date());
        info.setCreatetime(datetimeNow);
        info.setCreaterId(SPUtil.getstr_jdrusername(this));
        info.setSign("0");
        info.setSource("0");
        info.setIsUpdate("N");// Y未上传 N已上传
        info.setRes0(str_type);
        info.setRes1(uuid);
        List<JTYS_SignPictureData> pictures = NovaApplication.fdbmanger.findAllByWhere(JTYS_SignPictureData.class,
                "CardNum = '" + userinfo.getIDCARD() + "'");
        String type = JTYS_SignPictureData.type(imgPath);
        for (JTYS_SignPictureData data : pictures) {
            if (data.type() == type) {
                NovaApplication.fdbmanger.delete(data);
                try {
                    File f = new File(data.getPhotoPath());
                    if (f.exists()) {
                        f.delete();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        NovaApplication.fdbmanger.save(info);
    }*/



}
